package priv.wangy.micro.common.sync.constant;

import java.util.Arrays;
import java.util.Objects;

/**
 *@author wangy
 *@since 2024/12/2
 */
public enum DataSyncObjectEnum {
    /**
     * 基础服务
     */
    sch_company, industry, speciality, major_post, nationality, ethnicity,
    /**
     * 校务服务
     */
    department, org, calendar, classroom, office, dorm, train_base, cert,
    /**
     * 教学基础服务
     */
    teacher, major, subject, course, course_practice, rel_teacher_course, edu_scheme, tch_res_section,
    /**
     * 学生服务
     */
    classe, student, rel_classe_student,
    /**
     * 教学活动服务
     */
    tch_task_plan,
    /**
     * 更名或废弃
     */
    tln_dev_plan;

    private static final String QUEUE_NAME = "whmw.edu.%s.%s.queue";

    private static final String EXCHANGE_NAME = "whmw.edu.%s.exchange";

    public static DataSyncObjectEnum getByName(String name) {
        return Arrays.stream(DataSyncObjectEnum.values())
                .filter(sync -> Objects.equals(sync.toString(), name)).findFirst().orElse(null);
    }

    public String getQueueName(String alias) {
        return String.format(QUEUE_NAME, this, alias);
    }

    public String getExchangeName() {
        return String.format(EXCHANGE_NAME, this);
    }
}
